package com.mxpio.erp.common.plan.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.mxpioframework.security.annotation.Dict;
import com.mxpioframework.security.entity.BaseEntity;
import com.mxpioframework.security.entity.User;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.persistence.*;
import java.util.Date;
import java.util.List;

@Data
@EqualsAndHashCode(callSuper=false)
@Entity
@Table(name = "MB_ERP_PLAN_MPS_VERSION_TEMP")
@Schema(description="主计划版本temp")
public class MpsVersionTemp extends BaseEntity {

	private static final long serialVersionUID = 1L;
	
	@Id
	//@Generator(policy = BizCodeGeneratorPolicy.class)
	@Column(name = "ID_", length = 64)
	@Schema(description = "ID")
	private String id;

	//@Id
	//@Generator(policy = BizCodeGeneratorPolicy.class)
	@Column(name = "CODE_", length = 64)
	@Schema(description = "编号")
	private String code;
	
	@Column(name = "NAME_", length = 64)
	@Schema(description = "名称")
	private String name;
	
	@Column(name = "BPMN_STATUS_", length = 64)
	@Schema(description = "审核状态")
	@Dict(dicCode = "ERP_COMMON_BPMN_STATUS")
	private String bpmnStatus;

	/*@Column(name = "BPMN_TYPE_", length = 64)
	@Schema(description = "审核类型(新增/变更)")
	@Dict(dicCode = "ERP_COMMON_BPMN_STATUS")
	private String bpmnType;*/

	@Column(name = "TYPE_", length = 64)
	@Schema(description = "类别（静态计划/动态计划）")
	@Dict(dicCode = "ERP_PLAN_TYPE")
	private String type;
	
	@Column(name = "START_DATE_")
	@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
	@Schema(description = "开始时间")
	private Date startDate;
	
	@Column(name = "END_DATE_")
	@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
	@Schema(description = "结束时间")
	private Date endDate;
	
	@Column(name = "REVIEWER_", length = 64)
	@Schema(description = "审核人")
	@Dict(dicCode = "username", dicEntity = User.class, dicText = "nickname")
	private String reviewer;
	
	@Column(name = "REVIEW_TIME_")
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	@Schema(description = "审核时间")
	private Date reviewTime;

	@Column(name = "REVIEW_OPINION_", length = 300)
	@Schema(description = "审核意见")
	private String reviewOpinion;

	@Column(name = "TYPE_CODE_", updatable = false)
	@Schema(description = "业务类别(生成单号需要，无实际业务意义)")//生成单号需要，无业务意义
	private String typeCode= "MPS1";

	@Column(name = "CHANGE_REASON_", length = 300)
	@Schema(description = "变更事由")
	private String changeReason;

	@Column(name = "ROLL_PERIOD_")
	@Schema(description = "滚动周期")
	private String rollPeriod;
	@Transient
	@Schema(description = "计划清单")
	private List<MpsLineTemp> mpsLineTempList;
}
